package com.example.back.service;

import com.example.back.entity.Post;
import com.example.back.entity.otd.Posts;
import com.example.back.mapper.PostMapper;
import com.example.back.mapper.otd.PostsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PostService {
    @Autowired
    private PostMapper postMapper;
    @Autowired
    private PostsMapper postsMapper;
    public int addPost(Post post)
    {
       return postMapper.addPost(post);
    }
    public int deletePost(Integer id)
    {
        return postMapper.deletePost(id);
    }
    public int updatePost(Post post)
    {
        return postMapper.updatePost(post);
    }
    public int addBrowse(Integer id)
    {return postMapper.addBrowse( id);}  //增加浏览量
    public Post queryPostById(Integer id)
    {
        return postMapper.queryPostById(id);
    }

    public ArrayList<Post> queryPost(Post post)
    {
        return postMapper.queryPost(post);
    }
    public ArrayList<Post> getTopPostsByBrowse()
    {
        return postMapper.getTopPostsByBrowse();//获取浏览量top20
    }

    public ArrayList<Posts> getPostsAndUser(String text, String time) { return postsMapper.getPostsAndUser(text, time); }

    public List<String> getAllPostTimes() {
        return postMapper.getAllPostTimes();  // 调用Mapper方法
    }
}
